<?php
class IndexAction extends BaseAction
{
    /**
    +----------------------------------------------------------
    * 默认操作
    +----------------------------------------------------------
    */
    public function index()
    {
        $this->display('index');
    }
    
    /**
    +----------------------------------------------------------
    * 左侧菜单
    +----------------------------------------------------------
    */
    public function menu()
    {
        $menuid = intval($_REQUEST['menuid']);
        //左侧菜单
        $left_menu = $this->admin_menu($menuid);
		foreach ($left_menu as $key=>$val) {
		    $val['url'] = U($val['c'] . '/' . $val['a'], array('menuid'=>$val['id']));
		    $val['sub'] = $this->admin_menu($val['id']);
		    foreach ($val['sub'] as $skey=>$sval) {
		        $sval['url'] = U($sval['c'] . '/' . $sval['a'], array('menuid'=>$sval['id']));
		        $val['sub'][$skey] = $sval;
		    }
		    $left_menu[$key] = $val;
		}
        $this->assign('left_menu', $left_menu);
        $this->display('left');
    }
    
    /**
    +----------------------------------------------------------
    * 当前位置
    +----------------------------------------------------------
    */
    public function current_pos()
    {
        $menuid = intval($_REQUEST['menuid']);
        
        $r = M('menu')->field('id,name,pid')->where('id='.$menuid)->find();
		$str = '';
		if($r['pid']) {
		    $parent = M('menu')->field('id,name,pid')->where('id='.$r['pid'])->find();
		    $str = L($parent['name']).' > ';
		}
		$str .= L($r['name']);
        echo $str;
        exit;
    }
    
    /**
    +----------------------------------------------------------
    * 控制面板
    +----------------------------------------------------------
    */
    public function panel()
    {
        $this->display('panel');
    }
}
?>